package org.huanletao.ssm.exception;

import org.apache.shiro.authc.AuthenticationException;
import org.huanletao.ssm.model.RespBean;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * <p>
 * </p>
 * package: org.huanletao.ssm
 * description:
 * className: GobalExceptionHandler
 * author:  踏雪无痕
 * copyright: Copyright (c) 2022/8/27 11:04
 * since: 1.0.0
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 全局异常处理器；
     *
     * @param e
     * @return
     */
    @ExceptionHandler(RuntimeException.class)
    public String handle(RuntimeException e) {

        return "";
    }

    @ExceptionHandler(AuthenticationException.class)
    public RespBean handle(AuthenticationException e) {
        return RespBean.fail("认证失败："+e.getMessage(),"401");
    }

}
